Next | Prev | Up | Top | Contents | Index

Tuning the Geometry Subsystem

A number of optimizations are possible for the geometry subsystem:

Using Peak-Performance Primitives

This section describes how to draw geometry with optimal primitives. Consider these guidelines to optimize drawing:

Using Vertex Arrays

Vertex arrays are available in OpenGL 1.1 (see "OpenGL 1.1 Vertex Arrays"). They offer the following benefits:

One possible disadvantage to vertex arrays over using glBegin()/glEnd() is that it may require additional memory usage.

If you use glBegin()/glEnd() instead of glDrawArrays() or glDrawElements() calls, put as many vertices as possible between the glBegin() and the glEnd(). This amortizes the cost of the call and also makes it easier to batch vertices.

Note that in situations where vertices are shared, it makes sense to lock them down for optimum performance. See "The Compiled Vertex Arrays Extension."

Using Drawing Modes Appropriately

This section discusses ways of reducing per-vertex costs.

Using Fast Drawing Modes

For optimum performance, use flat shading whenever possible. This reduces the number of lighting computations from one per vertex to one per primitive, and also reduces the amount of data that must be processed for each primitive. This is particularly important for high-performance line drawing.

Using Expensive Modes Efficiently

OpenGL offers many features that create sophisticated effects with excellent performance. However, these features have some performance cost, compared to drawing the same scene without them. Use these features only where their effects, performance, and quality are justified.

Optimizing Lighting Performance

OpenGL offers a large selection of lighting features: The penalties some features carry may vary depending on the hardware you're running on. Be prepared to experiment with the lighting configuration.

As a general rule, use the simplest possible lighting model, a single infinite light with an infinite viewer. For some local effects, try replacing local lights with infinite lights and a local viewer.

Use the following settings for peak performance lighting:

In addition, follow these guidelines to achieve peak lighting performance:

Advanced Geometry-Limited Tuning Techniques

This section describes advanced techniques for tuning transform-limited drawing. Follow these guidelines to draw objects with complex surface characteristics:


Using Peak-Performance Primitives
Using Vertex Arrays
Using Drawing Modes Appropriately
Using Fast Drawing Modes
Using Expensive Modes Efficiently
Optimizing Lighting Performance
Advanced Geometry-Limited Tuning Techniques

Next | Prev | Up | Top | Contents | Index